package com.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.common.utils.base.UuidUtil;
import com.entity.ChanPing;
import com.entity.FuJianGuanXi;
import com.repository.CpDao;
import com.repository.FjgxDao;
import com.service.base.BaseServiceImp;

@Service("CpService")
public class CpServicelmp extends BaseServiceImp<ChanPing> implements CpService{
	@Autowired
	private FjgxDao fjgxdao; 
	@Autowired
	private CpDao dao;
	@Transactional
	@Override
	public void insertFj(ChanPing o, String fujianId) {
		String yhId=UuidUtil.get32UUID();
		o.setId(yhId);
		o.setTp(fujianId);
		
		super.insert(o);
		if(!fujianId.equals("")){
			if(fujianId.indexOf(",")>-1){
				String fujianIdArr[] = fujianId.split(",");
				for (int i = 0; i < fujianIdArr.length; i++) {
					FuJianGuanXi fjgx = new FuJianGuanXi();
					fjgx.setId(UuidUtil.get32UUID());
					fjgx.setScr(yhId);
					fjgx.setFjwjm("1");
					fjgx.setFjbh(fujianIdArr[i]);
					fjgxdao.insert(fjgx);
				}
			}else{
				FuJianGuanXi fjgx = new FuJianGuanXi();
				fjgx.setId(UuidUtil.get32UUID());
				fjgx.setScr(yhId);
				fjgx.setFjwjm("1");
				fjgx.setFjbh(fujianId);
				fjgxdao.insert(fjgx);
			}
		}
		
	}

	@Override
	public void deletes(ChanPing o) {
		dao.deletes(o);
		
	}
	@Override
	public void upcpzt(ChanPing o) {
		dao.upcpzt(o);
		
	}

	@Override
	public ChanPing findone(ChanPing o) {
		// TODO Auto-generated method stub
		return dao.findone(o);
	}

}